package com.hanfu.ucenter.web.web.service;

import com.hanfu.ucenter.web.dao.MerchantMapper;
import com.hanfu.ucenter.web.exception.ErrorCode;
import com.hanfu.ucenter.web.exception.UCenterException;
import com.hanfu.ucenter.web.web.param.union.ReqMerchantEnter;
import com.hanfu.ucenter.web.web.util.HttpClientUtil;
import com.hanfu.ucenter.web.web.util.HttpRequestUtil;
import com.hanfu.ucenter.web.web.util.UnionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: yQJun
 * Description： 商户认证业务处理
 * @Date：Created in 19:21  2019/9/19
 */

@Service
public class MerchantService {


    private final MerchantMapper memberMapper;

    @Autowired
    public MerchantService(MerchantMapper memberMapper) {
        this.memberMapper = memberMapper;
    }


    @Value("${yinlian.preURL}")
    private String MERPREURL;


    /**
     * 提交商户入住信息
     * */
    public Boolean submitMerchantEnter(ReqMerchantEnter req) throws UCenterException {
        if (memberMapper.findMerchant(req.getMemberId(),req.getShop_name())!=null) {
            throw new UCenterException(ErrorCode.SHOPNAME_REPETITION);
        }
        Map<String, String> map= UnionUtil.sign(req);

        Map<String,String> reqMap = new HashMap<>();
        reqMap.put("json_data",map.get("json_data"));
        reqMap.put("sign_data",map.get("sign_data"));
        reqMap.put("accesser_id",map.get("accesser_id"));
        System.out.println("ooooooooooo"+map);
        System.out.println(HttpClientUtil.httpPost(MERPREURL,reqMap));
        //System.out.println(HttpClientUtil.httpPost(MERPREURL,reqMap));
        System.out.println(map.get("param"));
        return null;
    }




}
